<div class="layui-card js-view-addArticle">
    <div class="layui-card-header">
        <a class="cl-38f" target="page" href="{:U('Article/index',['node_id'=>$nodeId])}">文章列表</a> / {$row?'编辑':'添加'}文章
    </div>
    <div class="layui-card-body">
        <form class="layui-form" method="post" action="{:U('Article/addArticle')}?id={$row.id??''}" lay-filter="js-view-addArticle-form">
            <div class="layui-tab">
                <ul class="layui-tab-title">
                    <li class="layui-this">基本信息</li>
                    <li>文章内容</li>
                    <li>高级参数</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <table>
                            <tr>
                                <th width="100"><em>*</em>文章标题</th>
                                <td>
                                    <input type="text" name="title" value="{$row.title??''}" lay-verify="required" autocomplete="off" class="layui-input" maxlength="200"/>
                                </td>
                            </tr>
                            <tr>
                                <th>所属栏目</th>
                                <td>
                                    <select name="node_id" lay-filter="article-node-id">
                                        <option value="">请选择所属栏目</option>
                                        {foreach $nodes as $item}
                                        <option value="{$item.id}" {if ($row&&$row['node_id']==$item['id'])||(!$row&&$nodeId==$item['id']) }selected{/if}>{:str_repeat('&nbsp;', ($item['depth'] - 1) * 4)}{$item.name}</option>
                                        {/foreach}
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>文章标签</th>
                                <td>
                                    <input type="checkbox" name="is_head" value="1" unvalue="0" title="头条[h]" lay-skin="primary" {$row.is_head?'checked':''}/>
                                    <input type="checkbox" name="is_recom" value="1" unvalue="0" title="推荐[c]" lay-skin="primary" {$row.is_recom?'checked':''}/>
                                    <input type="checkbox" name="is_special" value="1" unvalue="0" title="特荐[a]" lay-skin="primary" {$row.is_special?'checked':''}/>
                                </td>
                            </tr>
                            <tr>
                                <th>文章配图</th>
                                <td>
                                    {imgspace name="img" value="$row.img??''" title="文章配图" /}
                                </td>
                            </tr>
                            <tr>
                                <th>作者</th>
                                <td>
                                    <input type="text" name="author" value="{$row.author??''}" autocomplete="off" class="layui-input" maxlength="50"/>
                                </td>
                            </tr>
                            <tr>
                                <th>浏览量</th>
                                <td>
                                    <input type="text" name="view_count"  value="{$row.view_count??'0'}" lay-verify="number" autocomplete="off" class="layui-input" maxlength="10"/>
                                </td>
                            </tr>
                            <tr>
                                <th>发布时间</th>
                                <td>
                                    <input type="text" name="pubtime" value="{$row.pubtime??''}" placeholder="yyyy-MM-dd HH:mm:ss" class="layui-input layui-date" autocomplete="off" readonly/>
                                </td>
                            </tr>
                            <tr>
                                <th>发布</th>
                                <td>
                                    <input type="checkbox" name="ifpub" lay-skin="switch" lay-text="是|否" value="true" {if !isset($row['ifpub'])||$row['ifpub']!='false'}checked{/if} unvalue="false"/>
                                </td>
                            </tr>
                        </table>
                        <div class="js-custom-fields"></div>
                    </div>
                    <div class="layui-tab-item">
                        <div style="width: 780px;">
                            文章内容
                            <div class="mt10">
                                {editor name="content" type="ueditor" } {$row.content??''} {/editor}
                            </div>
                            <div class="mt10">手机端内容<span class="ml10 f12 cl-999">（选填）手机端模板内容，不设置默认和上面一样</span></div>
                            <div class="mt10">
                                {editor name="wap_content" type="ueditor"} {$row.wap_content??''} {/editor}
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">
                        <table lay-th-vtop>
                            <tr width="100">
                                <th>文章模板</th>
                                <td>
                                    <select name="tmpl_path">
                                        {foreach $templist as $key=>$item}
                                        <option value="{$key}" {if $row&&$key==$row['tmpl_path'] }selected{/if}>{$item}</option>
                                        {/foreach}
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>文章来源</th>
                                <td>
                                    <input type="text" name="source" value="{$row.source??''}" placeholder="文章来源" autocomplete="off" class="layui-input" maxlength="100"/>
                                </td>
                            </tr>
                            <tr>
                                <th>来源网址</th>
                                <td>
                                    <input type="text" name="source_url" value="{$row.source_url??''}" placeholder="来源网址 http://" autocomplete="off" class="layui-input" maxlength="200"/>
                                </td>
                            </tr>
                            <tr>
                                <th>SEO标题</th>
                                <td>
                                    <input type="text" name="seo_title" value="{$row.seo_title??''}"  autocomplete="off" class="layui-input" placeholder="SEO标题" maxlength="150" />
                                    <p class="cl-888 mt5 f12"> 一般不超过80个字符，为空时默认文章标题 </p>
                                </td>
                            </tr>
                            <tr>
                                <th>SEO关键词</th>
                                <td>
                                    <input type="text" name="seo_keywords" value="{$row.seo_keywords??''}" autocomplete="off" class="layui-input" placeholder="SEO关键词" maxlength="150"/>
                                    <p class="cl-888 mt5 f12"> 一般不超过100个字符，多个关键词请用英文逗号","隔开，建议3到5个关键词</p>
                                </td>
                            </tr>
                            <tr>
                                <th>SEO描述</th>
                                <td>
                                    <textarea name="seo_description" class="layui-textarea" placeholder="SEO描述">{$row.seo_description??''}</textarea>
                                    <p class="cl-888 mt5 f12"> 一般不超过200个字符，不填写时系统自动提取正文的前200个字符</p>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <div class="mt30 pl100 pb30">
                <button class="layui-btn layui-btn-normal" lay-submit>确认提交</button>
            </div>
        </form>
    </div>
</div>
{include file="seo/zzbaidu" view="js-view-addArticle"/}
<script>
    (function () {
        var $view = $('.js-view-addArticle');

        function getCustomFieldHtml(typeId) {
            var p = {
                type: 'articles',
                typeId: typeId,
                dataId: '{$row.id??0}',
                thWidth: '100',
            };
            $.post('{:U("Channeltype/getCustomFieldHtml")}', p, function (rs) {
                $('.js-custom-fields', $view).html(rs);
                layui.form.render(null, 'js-view-addArticle-form');
            });
        }

        getCustomFieldHtml($('[name="node_id"]', $view).val());
        layui.form.on('select(article-node-id)', function (data) {
            getCustomFieldHtml(data.value);
        });
    })();
</script>